package easy;

public class Solution_1544 {

    public String makeGood(String s) {
        char[] chars = s.toCharArray();
        int index = 0;
        for (int i = 1; i < chars.length; i++) {
            if (index == -1) {
                index++;
                chars[index] = chars[i];
            } else {
                if (chars[i] - chars[index] == 32 || chars[index] - chars[i] == 32) {
                    index--;
                } else {
                    chars[++index] = chars[i];
                }
            }

        }
        return new String(chars, 0, index + 1);
    }

    public static void main(String[] args) {
        Solution_1544 model = new Solution_1544();
        System.out.println(model.makeGood("leEeetcode"));
        System.out.println(model.makeGood("abBAcC"));
        System.out.println(model.makeGood("s"));
    }
}
